package com.it.park.controller.admin;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.it.park.client.service.VisitInfoService;
import com.it.park.common.Page;
import com.it.park.constant.Constant;
import com.it.park.model.VisitInfo;

@Controller
@RequestMapping("/admin/log/visit")
public class AdminVisitController {

	@Autowired
	private VisitInfoService visitInfoService;
	
	private Page page = null;
	
	private String rootPath=Constant.ADMIN_PATH;


	@RequestMapping("listRows")
	@ResponseBody
	public Map<String,Object> listRows(HttpServletRequest request){
			int pageNow = Integer.parseInt(request.getParameter("page"));
			int rows = Integer.parseInt(request.getParameter("rows"));
			Map<String,Object> map_ = new HashMap<String, Object>();
			Integer total = visitInfoService.selectTotal(map_);
			page = new Page(page != null?pageNow:1,total,rows);
			map_.put("startPos", page.getStartPos());
			map_.put("pageSize", page.getPageSize());
			List<VisitInfo> list = visitInfoService.selectPagination(map_);
			Map<String,Object> map  =new HashMap<String, Object>();
			map.put("total", total);
			map.put("rows", list);
			return map;
	} 
	
	/*访问者日志页面*/
	@RequestMapping("visitList")
	public String visitList(HttpServletRequest request){
			return rootPath+"log/visit/visitList";
	}
	
}
